import axios from "axios";

let request = axios.create({
  baseURL: "http://localhost:8081",
  timeout: 5000,
});

// 拦截器
request.interceptors.request.use((config) => {
    return config;
});

request.interceptors.response.use(
    (response) => {
        // 成功响应
        return response.data;
    },
    (error) => {
        // 失败响应
        let message = "";

        let status = error.response.status;
        switch(status) {
            case 400:
                message = "请求参数错误";
                break;
        }

        // ElMessage.error(message);

        return Promise.reject(error);
    }
);

export default request;